﻿using KalevaAalto.CollectionPart;
using KalevaAalto.DataPart.Enums;
using KalevaAalto.DataPart.Models;
using OfficeOpenXml.Style;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace KalevaAalto.DataPart.Excel.Epplus
{
    internal class EpplusBorder : IBorder
    {
        private readonly ExcelStyle _style;
        public EpplusBorder(ExcelStyle style)
        {
            _style = style;
        }

        private static readonly ITwoWayDictionary<BorderStyle, ExcelBorderStyle> s_borders = new TwoWayDictionary<BorderStyle, ExcelBorderStyle>()
        {
            { BorderStyle.None,ExcelBorderStyle.None },
            { BorderStyle.Thin,ExcelBorderStyle.Thin },
            { BorderStyle.Thick,ExcelBorderStyle.Thick },
        };

        BorderStyle IBorder.Left { get => s_borders.GetValueBySecond(_style.Border.Left.Style); set => _style.Border.Left.Style = s_borders.GetValueByFirst(value); }
        BorderStyle IBorder.Right { get => s_borders.GetValueBySecond(_style.Border.Right.Style); set => _style.Border.Right.Style = s_borders.GetValueByFirst(value); }
        BorderStyle IBorder.Top { get => s_borders.GetValueBySecond(_style.Border.Top.Style); set => _style.Border.Top.Style = s_borders.GetValueByFirst(value); }
        BorderStyle IBorder.Bottom { get => s_borders.GetValueBySecond(_style.Border.Bottom.Style); set => _style.Border.Bottom.Style = s_borders.GetValueByFirst(value);  }
    }
}
